<?php

use yii\db\Migration;

/**
 * Class m180523_061706_alter_table_user_add_token_cols
 */
class m180523_061706_alter_table_user_add_token_cols extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {
        $sql = <<<EOF
        ALTER TABLE `ehr`.`user` 
        ADD COLUMN `access_token` VARCHAR(45) NULL COMMENT 'restful请求token' AFTER `mobile`,
        ADD COLUMN `allowance` INT NULL COMMENT 'restful剩余的允许的请求数' AFTER `access_token`,
        ADD COLUMN `allowance_updated_at` INT NULL COMMENT 'restful请求的时间戳数' AFTER `allowance`;

EOF;
        $this->execute($sql);
    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {
        echo "m180523_061706_alter_table_user_add_token_cols cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180523_061706_alter_table_user_add_token_cols cannot be reverted.\n";

        return false;
    }
    */
}
